#!/usr/bin/python
# -*- coding: UTF-8 -*-
'''
汤臣倍健销售分析
'''
import pandas as pd
import pymongo
from config import *
import numpy as np
import matplotlib.pyplot as plot
import jieba.analyse
from io import StringIO
import re
import json
from tcbj.DataFilter import datafilter
import json
plot.rcParams['font.sans-serif'] = ['SimHei']
plot.rcParams['font.family']='sans-serif'

client=pymongo.MongoClient(MONGO_URL);
db=client["tcbj"]
MONGO_TABLE="201804"

dest=set()
#获取数据
def getData():
    queryArgs = {}
    projectionFields = {'_id': False,"img":False}  # 用字典指定
    result = db["201804"].find(queryArgs, projection=projectionFields)
    return result


def to_csv():
    data = pd.DataFrame(list(getData()))
    data.to_csv("tcbj_201804.csv", encoding="utf-8",index_col="deal")





def main():
    data=pd.read_csv("test.csv",encoding="utf-8")

    # for index,row in data.iterrows():
    #     dat=row.to_dict()
    #     saveToMongo(dat)


        # saveToMongo(dd)




        # saveToMongo(dd)





def saveToMongo(result):
    try:
        if db[MONGO_TABLE].insert(result):
            print("save result success");
    except Exception as e:
        print(e)
        print("save mongo error")



if __name__ == '__main__':
    main()







